package bTree.LeetCode;

import java.util.LinkedList;
import java.util.Queue;

public class 找树左下角的值 {
    public int findBottomLeftValue(TreeNode root) {
        Queue<TreeNode>queue=new LinkedList<TreeNode>();
        queue.add(root);
        int result=root.val;
        while (!queue.isEmpty()){
            int size = queue.size();
            result=queue.peek().val;
            for (int i = 0; i < size; i++) {
                if (queue.peek().left!=null){
                    queue.add(queue.peek().left);
                }
                if (queue.peek().right!=null){
                    queue.add(queue.peek().right);
                }
                queue.poll();
            }
        }
        return result;
    }
}